﻿using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Battle.Engine.LogicModel
{
    public class FSkillCast
    {
        public TableSkillCast castData;
        public string id;
        public SpeState causeSpeState;
        public SpeState advSpeState;
        public int selectStrategy;
        public double exportFactor; //技能系数
        public AttackType exportType; //输出类型
        public double addAnger;
        public List<FSkillBuff> skillBuffs;

        public FSkill skill;

        public void init(FSkill skill, TableSkillCast tData)
        {
            this.skill = skill;
            this.castData = tData;
            this.id = this.castData.SkillCastId;
            this.causeSpeState = (SpeState)this.castData.CauseSpeState;
            this.advSpeState = (SpeState)this.castData.AdvSpeState;
            this.selectStrategy = this.castData.SelectStrategy;
            this.exportFactor = this.castData.ExportFactor*CommonMethod.tableAttributeConvert;
            this.exportType = (AttackType)this.castData.ExportType;
            this.addAnger = this.castData.AddAnger;

            skillBuffs = new List<FSkillBuff>();
            for (int i = 0; i < this.castData.BufferId_array.Length; i++)
            {
                if (!string.IsNullOrEmpty(castData.BufferId_array[i]))
                {
                    TableBuff tb = this.skill.actor.player.engineData.tableDataUtil.GetTableBuff(castData.BufferId_array[i]);
                    if (tb != null)
                    {
                        var skillBuff = new FSkillBuff(this, this.castData.BufferId_array[i], (BUFFHitClass)this.castData.BuffTriggerClass_array[i], (BuffTriggerCondition)this.castData.BuffTriggerCondition_array[i], this.castData.BuffConditionArgs_array[i], this.castData.BufferPercent_array[i], this.castData.BuffSelStr_array[i]);
                        skillBuffs.Add(skillBuff);
                    }
                }
            }

        }

        public void ResetRound(EngineData data)
        {

        }
    }
}
